package com.dps.omc.action;

import com.dps.omc.model.Server;
import com.dps.omc.service.IServerService;
import com.dps.omc.shell.ServerParaMap;
import com.dps.omc.shell.ShellClient;
import com.dps.omc.shell.ShellSessions;
import com.dps.omc.shell.WsSender;
import com.jcraft.jsch.JSchException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by lip on 2016-07-07.
 */

@Controller
public class ConsoleAction extends BaseAction{

    @Autowired
    private IServerService serverService;

    @RequestMapping(value="/console")
    public String termimal(ModelMap model, HttpServletRequest request, HttpServletResponse response){

        return "/console/console";
    }

    @RequestMapping(value="/console/xterm")
    public String xterm(String serverId,ModelMap model, HttpServletRequest request, HttpServletResponse response){
        Server server = serverService.fetch(serverId);
        ServerParaMap.putServer(serverId,server);

        model.addAttribute("server",server);
        model.addAttribute("serverId",serverId);
        return "/console/xterm";
    }
}
